package com.bw.goods.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.goods.R;
import com.youth.banner.adapter.BannerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class HomeTextBannerAdapter extends BannerAdapter<String, HomeTextBannerAdapter.HomeTextViewHolder> {

    public HomeTextBannerAdapter(List<String> datas) {
        super(datas);
    }

    @Override
    public HomeTextViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        View textView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_txt_banner
        ,parent,false);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
        );
        textView.setLayoutParams(layoutParams);
        return new HomeTextViewHolder(textView);
    }

    @Override
    public void onBindView(HomeTextViewHolder holder, String data, int position, int size) {
        holder.textBannerItem.setText(data);
    }

    public static class HomeTextViewHolder extends RecyclerView.ViewHolder {
        TextView textBannerItem;
        public HomeTextViewHolder(@NonNull @NotNull View itemView) {
            super(itemView);
            textBannerItem = itemView.findViewById(R.id.txtbanner_item);
        }
    }
}
